﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AdaptationProject.Properties;
using AdaptationProject.Utils;

namespace AdaptationProject
{
    // Отображение списка отчетов
    public partial class Reports : Form
    {
        private FileInfo[] files;

        public Reports()
        {
            InitializeComponent();
        }

        private void Reports_Load(object sender, EventArgs e)
        {
            DirectoryInfo dirInfo = new DirectoryInfo(MySettings.ReportsStoragePath);
            files = dirInfo.GetFiles("*.html");
            for(int i = 0; i < files.Length; i++)
            {
                listBox1.Items.Add(files[i].Name);
            }
            files = dirInfo.GetFiles("*.txt");
            for (int i = 0; i < files.Length; i++)
            {
                listBox1.Items.Add(files[i].Name);
            }
        }

        private void btnOpen_Click(object sender, EventArgs e)
        {
            Process.Start(string.Format(@"{0}\{1}", MySettings.ReportsStoragePath,
                                        listBox1.Items[listBox1.SelectedIndex].ToString()));
        }

        private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Process.Start(string.Format(@"{0}\{1}", MySettings.ReportsStoragePath,
                                        listBox1.Items[listBox1.SelectedIndex].ToString()));
        }
    }
}
